﻿
@using Blazor.Diagrams.Components
@using AntDesign
@using AntDesign.ProLayout;
@using AntDesign.Core;
@using AntDesign.TableModels;
@using ERP.Workflow.Designer.BlazorUI.Core
@using ERP.Workflow.Designer.BlazorUI.Helper
@using  ERP.Workflow.Designer.BlazorUI.Models

@implements IPropertyBox<FlowNode>
@inject ToolBoxProvider ToolBoxProvider
@inject IStringLocalizer<WorkflowDesignerResource> L

<Tabs  Animated  Centered  @bind-ActiveKey="@activeKey"     >
	  <TabPane Tab="基本信息" Key="1"  >
                <Row  Class="row">
                      <AntDesign.Col Span="10"  Class="col l"><lable class="lable">@L["Title"]</lable></AntDesign.Col>
                      <AntDesign.Col Span="14" Class="col">
                           <Input Size="small" style="width:120px;"  @bind-Value="Data.Title" TValue="string"   OnChange="(e)=>Change(nameof(FlowNode.Title),e)" ></Input>
                        </AntDesign.Col>       
                 </Row>  
                 <Row Class="row">
                      <AntDesign.Col Span="10"  Class="col l"><lable class="lable">@L["Title"]</lable></AntDesign.Col>
                      <AntDesign.Col Span="14" Class="col">
                           <Input  Size="small" style="width:120px;" @bind-Value="Data.Code" TValue="string"   OnChange="(e)=>Change(nameof(FlowNode.Code),e)"  ></Input>
                        </AntDesign.Col>       
                 </Row>
                 <Row Class="row">
                      <AntDesign.Col Span="10"  Class="col l"><lable class="lable">@L["OrderNo"]</lable></AntDesign.Col>
                      <AntDesign.Col Span="14" Class="col">
                           <Input Size="small" style="width:120px;"  @bind-Value="Data.OrderNo" TValue="int?"  OnChange="(e)=>Change(nameof(FlowNode.OrderNo),e) " ></Input>
                        </AntDesign.Col>       
                 </Row>  
                 <Row Class="row">
                      <AntDesign.Col Span="10"  Class="col l"><lable class="lable">@L["NodeType"]</lable></AntDesign.Col>
                      <AntDesign.Col Span="14" Class="col">
                         <Select Size="small" style="width:120px;"  DataSource="NodeTypeList"  ValueChanged="(e)=>{Data.NodeType=e;Change(nameof(FlowNode.NodeType),e);}"   TItem="EmenItem"  TItemValue="NodeType"  Value="@Data.NodeType" LabelName="@nameof(EmenItem.Descripton)" ValueName="@nameof(EmenItem.Value)"   ></Select>
                      </AntDesign.Col>       
                 </Row>  
                 <Row Class="row">
                      <AntDesign.Col Span="10"  Class="col l"><lable class="lable">@L["ModeType"]</lable></AntDesign.Col>
                      <AntDesign.Col Span="14" Class="col">
                         <Select Size="small" style="width:120px;"  DataSource="ModeTypeTypeList"    ValueChanged="(e)=>{Data.ModeType=e;Change(nameof(FlowNode.ModeType),e);}"    TItem="EmenItem"  TItemValue="ModeType" Value="@Data.ModeType" LabelName="@nameof(EmenItem.Descripton)" ValueName="@nameof(EmenItem.Value)"   ></Select>
                      </AntDesign.Col>       
                 </Row>  
                  <Row Class="row">
                      <AntDesign.Col Span="10"  Class="col l"><lable class="lable">@L["IsCanChangeActor"]</lable></AntDesign.Col>
                      <AntDesign.Col Span="14" Class="col">
                            <Switch Size="small" ValueChanged="(e)=>{Data.IsCanChangeActor=e;Change(nameof(FlowNode.IsCanChangeActor),e);}"    Value="@Data.IsCanChangeActor" ></Switch>
                      </AntDesign.Col>       
                 </Row>  
                 <Row Class="row">
                      <AntDesign.Col Span="10"  Class="col l"><lable class="lable">@L["IsCanTransfer"]</lable></AntDesign.Col>
                      <AntDesign.Col Span="14" Class="col">
                        <Switch Size="small" OnChange="(e)=>{Change(nameof(FlowNode.IsCanTransfer),e); }"   @bind-Value="@Data.IsCanTransfer" ></Switch>
                      </AntDesign.Col>       
                 </Row>  
                 <Row Class="row">
                      <AntDesign.Col Span="10"  Class="col l"><lable class="lable">@L["IsCanChangeTransfer"]</lable></AntDesign.Col>
                      <AntDesign.Col Span="14" Class="col">
                <Switch Size="small" OnChange="(e)=>{Change(nameof(FlowNode.IsCanChangeTransfer),e); }" @bind-Value="@Data.IsCanChangeTransfer"></Switch>
                      </AntDesign.Col>       
                 </Row>

         
                 <Row Class="row">
                      <AntDesign.Col Span="10"  Class="col l"><lable class="lable">@L["IsCanCirculated"]</lable></AntDesign.Col>
                      <AntDesign.Col Span="14" Class="col">
                        <Switch Size="small"  OnChange="(e)=>{Change(nameof(FlowNode.IsCanCirculated),e); }"     @bind-Value="@Data.IsCanCirculated" ></Switch>
                      </AntDesign.Col>       
                 </Row>  
                <Row Class="row">
                      <AntDesign.Col Span="10"  Class="col l"><lable class="lable">@L["IsCanChangeCirculated"]</lable></AntDesign.Col>
                      <AntDesign.Col Span="14" Class="col">
                            <Switch Size="small"  ValueChanged="(e)=>{Data.IsCanChangeCirculated=e;Change(nameof(FlowNode.IsCanChangeCirculated),e);}"    Value="@Data.IsCanChangeCirculated" ></Switch>
                      </AntDesign.Col>       
                 </Row>

         
             <Row Class="row">
                      <AntDesign.Col Span="10"  Class="col l"><lable class="lable">@L["IsAppend"]</lable></AntDesign.Col>
                      <AntDesign.Col Span="14" Class="col">
                        <Switch Size="small"    OnChange="(e)=>{Change(nameof(FlowNode.IsAppend),e); }"       @bind-Value="@Data.IsAppend" ></Switch>
                      </AntDesign.Col>       
                 </Row>  

                 <Row Class="row">
                      <AntDesign.Col Span="10"  Class="col l"><lable class="lable">@L["IsCanComments"]</lable></AntDesign.Col>
                      <AntDesign.Col Span="14" Class="col">
                        <Switch Size="small"    OnChange="(e)=>{Change(nameof(FlowNode.IsCanComments),e); }"       @bind-Value="@Data.IsCanComments" ></Switch>
                      </AntDesign.Col>       
                 </Row>  
                 <Row Class="row">
                      <AntDesign.Col Span="10"  Class="col l"><lable class="lable">@L["Title"]</lable></AntDesign.Col>
                      <AntDesign.Col Span="14" Class="col">
                        <Switch Size="small"  OnChange="(e)=>{Change(nameof(FlowNode.IsCanRejected),e); }"        @bind-Value="@Data.IsCanRejected" ></Switch>
                      </AntDesign.Col>       
                 </Row>  
                 <Row Class="row">
                      <AntDesign.Col Span="10"  Class="col l"><lable class="lable">@L["IsCanWithdraw"]</lable></AntDesign.Col>
                      <AntDesign.Col Span="14" Class="col">
                        <Switch  Size="small" OnChange="(e)=>{Change(nameof(FlowNode.IsCanWithdraw),e); }"        @bind-Value="@Data.IsCanWithdraw" ></Switch>
                      </AntDesign.Col>       
                 </Row>  
                 <Row Class="row">
                      <AntDesign.Col Span="10"  Class="col l"><lable class="lable">@L["IsCanEditForm"]</lable></AntDesign.Col>
                      <AntDesign.Col Span="14" Class="col">
                        <Switch Size="small"  OnChange="(e)=>{Change(nameof(FlowNode.IsCanEditForm),e); }"         @bind-Value="@Data.IsCanEditForm" ></Switch>
                      </AntDesign.Col>       
                 </Row>  
                  <Row Class="row">
                      <AntDesign.Col Span="10"  Class="col l"><lable class="lable">@L["IsFree"]</lable></AntDesign.Col>
                      <AntDesign.Col Span="14" Class="col">
                      <Switch Size="small" OnChange="(e)=>{Change(nameof(FlowNode.IsFree),e); }" @bind-Value="@Data.IsFree"></Switch>
                      </AntDesign.Col>       
                 </Row>  


        </TabPane>
          <TabPane Tab="路由信息" Key="2"  >
                <Row Class="row">
                      <AntDesign.Col Span="10"  Class="col l"><lable class="lable">@L["SplitRule"]</lable></AntDesign.Col>
                      <AntDesign.Col Span="14" Class="col">
                         <Select Size="small" style="width:120px;" ValueChanged="(e)=>{Data.SplitRule=e;Change(nameof(FlowNode.SplitRule),e);}"      DataSource="SplitRuleList" TItemValue="SplitRule" Value="@Data.SplitRule"  OnChange="(e)=>StateHasChanged()"  TItem="EmenItem"   LabelName="@nameof(EmenItem.Descripton)" ValueName="@nameof(EmenItem.Value)"   ></Select>
                      </AntDesign.Col>       
                 </Row>  
                <Row Class="row">
                      <AntDesign.Col Span="10"  Class="col l"><lable class="lable">@L["JoinRule"]</lable></AntDesign.Col>
                      <AntDesign.Col Span="14" Class="col">
                         <Select Size="small" style="width:120px;"  ValueChanged="(e)=>{Data.JoinRule=e;Change(nameof(FlowNode.JoinRule),e);}"     DataSource="JoinRuleList" TItemValue="JoinRule" Value="@Data.JoinRule"  OnChange="(e)=>StateHasChanged()"  TItem="EmenItem"   LabelName="@nameof(EmenItem.Descripton)" ValueName="@nameof(EmenItem.Value)"   ></Select>
                      </AntDesign.Col>       
                 </Row>  
                 <Row Class="row">
                      <AntDesign.Col Span="10"  Class="col l"><lable class="lable">@L["ReposeType"]</lable></AntDesign.Col>
                      <AntDesign.Col Span="14" Class="col">
                         <Select Size="small" style="width:120px;"  ValueChanged="(e)=>{Data.ReposeType=e;Change(nameof(FlowNode.ReposeType),e);}"   DataSource="ReposeTypeList" TItemValue="ReposeType" Value="@Data.ReposeType"  OnChange="(e)=>StateHasChanged()"  TItem="EmenItem"   LabelName="@nameof(EmenItem.Descripton)" ValueName="@nameof(EmenItem.Value)"   ></Select>
                      </AntDesign.Col>       
                 </Row>  
                 <Row Class="row">
                      <AntDesign.Col Span="10"  Class="col l"><lable class="lable">@L["EntyType"]</lable></AntDesign.Col>
                      <AntDesign.Col Span="14" Class="col">
                         <Select Size="small" style="width:120px;" ValueChanged="(e)=>{Data.EntyType=e;Change(nameof(FlowNode.EntyType),e);}"   DataSource="EntyTypeList" TItemValue="EntyType" Value="@Data.EntyType"  OnChange="(e)=>StateHasChanged()"  TItem="EmenItem"   LabelName="@nameof(EmenItem.Descripton)" ValueName="@nameof(EmenItem.Value)"   ></Select>
                      </AntDesign.Col>       
                 </Row>  
                <Row Class="row">
                      <AntDesign.Col Span="10"  Class="col l"><lable class="lable">@L["ExitType"]</lable></AntDesign.Col>
                      <AntDesign.Col Span="14" Class="col">
                         <Select  Size="small" style="width:120px;" ValueChanged="(e)=>{Data.ExitType=e;Change(nameof(FlowNode.ExitType),e);}"  DataSource="ExitTypeList" TItemValue="ExitType" Value="@Data.ExitType"  OnChange="(e)=>StateHasChanged()"  TItem="EmenItem"   LabelName="@nameof(EmenItem.Descripton)" ValueName="@nameof(EmenItem.Value)"   ></Select>
                      </AntDesign.Col>       
                 </Row>
                 <Row Class="row">
                      <AntDesign.Col Span="10"  Class="col l"><lable class="lable">@L["ActorAssembly"]</lable></AntDesign.Col>
                      <AntDesign.Col Span="14" Class="col">
                            <Input Size="small" style="width:120px;"   OnChange="(e)=>Change(nameof(FlowNode.ActorAssembly),e)"   @bind-Value="Data.ActorAssembly" TValue="string"  ></Input>
                      </AntDesign.Col>       
                 </Row>  


                 <Row Class="row">
                      <AntDesign.Col Span="10"  Class="col l"><lable class="lable">@L["CirculatedAssembly"]</lable></AntDesign.Col>
                      <AntDesign.Col Span="14" Class="col">
                            <Input Size="small" style="width:120px;"  OnChange="(e)=>Change(nameof(FlowNode.CirculatedAssembly),e)"    @bind-Value="Data.CirculatedAssembly" TValue="string"  ></Input>
                      </AntDesign.Col>       
                 </Row> 


              <Row Class="row">
                      <AntDesign.Col Span="10"  Class="col l"><lable class="lable">@L["HasHistoryCanSkip"]</lable></AntDesign.Col>
                      <AntDesign.Col Span="14" Class="col">
                            <Switch Size="small"   ValueChanged="(e)=>{Data.HasHistoryCanSkip=e;Change(nameof(FlowNode.HasHistoryCanSkip),e);}"     Value="@Data.HasHistoryCanSkip" ></Switch>
                      </AntDesign.Col>       
                 </Row>  
                   <Row Class="row">
                      <AntDesign.Col Span="10"  Class="col l"><lable class="lable">@L["NotActorIsCanSkip"]</lable></AntDesign.Col>
                      <AntDesign.Col Span="14" Class="col">
                            <Switch Size="small"    ValueChanged="(e)=>{Data.NotActorIsCanSkip=e;Change(nameof(FlowNode.NotActorIsCanSkip),e);}"  Value="@Data.NotActorIsCanSkip" ></Switch>
                      </AntDesign.Col>       
                 </Row>  
                 <Row Class="row">
                      <AntDesign.Col Span="10"  Class="col l"><lable class="lable">@L["NotActorDefault"]</lable></AntDesign.Col>
                      <AntDesign.Col Span="14" Class="col">
                           <Input Size="small" Style="width:120px;"   OnChange="(e)=>Change(nameof(FlowNode.NotActorDefault),e)"    @bind-Value="Data.NotActorDefault" TValue="string"  ></Input>
                      </AntDesign.Col>       
                 </Row>  


          </TabPane>
</Tabs>
@code {
    private string activeKey = TabItems.BaseInfo;
    private IEnumerable<EmenItem> NodeTypeList = EnumHelper.GetValueLabelList(typeof(NodeType))
                .Select(m => new EmenItem { Descripton = m.Label, Value = m.Value });
    private IEnumerable<EmenItem> JoinRuleList = EnumHelper.GetValueLabelList(typeof(JoinRule))
                    .Select(m => new EmenItem { Descripton = m.Label, Value = m.Value });
    private IEnumerable<EmenItem> ReposeTypeList = EnumHelper.GetValueLabelList(typeof(ReposeType))
                    .Select(m => new EmenItem { Descripton = m.Label, Value = m.Value });
    private IEnumerable<EmenItem> EntyTypeList = EnumHelper.GetValueLabelList(typeof(EntyType))
                   .Select(m => new EmenItem { Descripton = m.Label, Value = m.Value });                           
    private IEnumerable<EmenItem> ExitTypeList = EnumHelper.GetValueLabelList(typeof(ExitType))
                   .Select(m => new EmenItem { Descripton = m.Label, Value = m.Value });                           
    private IEnumerable<EmenItem> ModeTypeTypeList = EnumHelper.GetValueLabelList(typeof(ModeType))
                   .Select(m => new EmenItem { Descripton = m.Label, Value = m.Value });            
                   
    private IEnumerable<EmenItem> SplitRuleList = EnumHelper.GetValueLabelList(typeof(SplitRule))
                   .Select(m => new EmenItem { Descripton = m.Label, Value = m.Value });       

    [Parameter] public FlowNode Data { get; set; } = new FlowNode();
    [Parameter] public EventCallback<PropertyChangeEventArg> OnChange { get; set; }
    public class EmenItem
    {
        public object? Value { get; set; }
        public string? FieldName { get; set; }
        public string? Descripton { get; set; }
    }
    protected  override Task OnInitializedAsync()
    {

        return base.OnInitializedAsync();
    }
    public virtual void Refresh()
    {
        StateHasChanged();
    }
    void Change(string Field, object val)
    {
      
        OnChange.InvokeAsync(new PropertyChangeEventArg { Data = Data, FieldName = Field, Value = val });
    }
  

  

}

